package login;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LoginServlet extends HttpServlet {
	private static final long serialVersionUID = -5389109687290129891L;

	@Override
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws IOException {
		response.setContentType("text/html;charset=GB2312");// 设置响应的MIME类型。
		java.io.PrintWriter out = response.getWriter();

		String type = request.getParameter("typeId");
		if (type.trim().equals("login")) {
			String name = request.getParameter("name");// 获取视图里的name
			String pas = request.getParameter("pas");// 获取视图里的password
			Model newModel = new Model();// 调用模型
			newModel.setName(name);
			newModel.setPas(pas);
			if (newModel.login()) {
				out.print("script Lanuage='JavaScript'>window.alert('登录成功！')</script>");
			} else {
				out.print("script Lanuage='JavaScript'>window.alert('登录失败！')</script>");
			}
		}
	}
}
